﻿#pragma once

namespace ljp
{
	template<class K,class V>
	class map
	{
		struct MapKeyOfT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename RBTree<K, pair<const K, V>, MapKeyOfT>::Iterator iterator;
		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
		bool insert(const pair<K,V>& kv)
		{
			return _t.Insert(kv);
		}

	private:
		RBTree<K, pair<const K, V>, MapKeyOfT> _t;

	};

	


	void test_map()
	{
		map<string, int> m;
		m.insert({ "hnj",1 });
		m.insert({ "li",1 });
		m.insert({ "sd",1 });
		m.insert({ "dsa",3 });
		map<string, int>::iterator it = m.begin();
		while (it != m.end())
		{
			//it->first += 'x';
			//it->second += 1;

			//cout << it.operator->()->first << ":" << it->second << endl;
			cout << it->first << ":" << it->second << endl;
			++it;
		}
		cout << endl;
	}
}